package com.gcph.zhuoba.main.common;

import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.MediaController;
import android.widget.ProgressBar;
import android.widget.VideoView;

import com.gcph.zhuoba.R;
import com.gcph.zhuoba.main.activitys.TeachingMainActivity;
import com.gcph.zhuoba.main.bean.Desk;

/**
 * 公共录像播放功能
 * @author zhanghejie
 */
public class CommonVedioActivity extends BaseActivity {

	private VideoView video_view;
	private String videoFileUrl;
	private Button btn_common_video_quit;
	private ProgressBar loading_video;
	private FrameLayout video_frame;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_common_vedio);
		videoFileUrl = this.getIntent().getStringExtra("videoFileUrl");
		//String uri = getResources().getString(R.string.server_root_url) + videoFileUrl;
		
		btn_common_video_quit = (Button) this.findViewById(R.id.btn_common_video_quit);
		loading_video = (ProgressBar) this.findViewById(R.id.loading_video);
		video_frame = (FrameLayout) this.findViewById(R.id.video_frame);
		
		video_view = (VideoView) this.findViewById(R.id.common_video_view);
		
		this.downLoadVedio(this, video_view, videoFileUrl);
//		video_view.setVideoURI(Uri.parse(uri));
//		MediaController mediaco = new MediaController(this);
//		video_view.setMediaController(mediaco);
//		mediaco.setMediaPlayer(video_view);
		
		video_view.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
			@Override
			public void onPrepared(MediaPlayer mp) {
				//loading_video.setAlpha(0);
				video_frame.removeView(loading_video);
				video_view.seekTo(1);
				video_view.start();
			}
		});
		
		btn_common_video_quit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
            	finish();
            }
		});
	}
}